<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"  %>

<script type="text/javascript">

$(document).ready(function() {
		$('#newUserDiv').hide();	
	});


function showDiv(){
	$('#newUserDiv').toggle();
}


$(function() {

	$('#saveUserPersonX').validate(
		{
		submitHandler : function(form) {
			$.post('./userperson/saveUserPerson.action?creandoCuenta=true', $('#saveUserPersonX').serialize(),
					function(respuesta) {
						$.post('./userperson/loadUserPersonForm.action', function(resultadoHTML) {
							$('#formAddUser').html(resultadoHTML);
						});
						
					});
		}
	});
});



</script>

<s:property value="msg"/>

<s:form id="saveUserPersonX" cssClass="well form-horizontal" theme="simple">
	<fieldset>

		<s:hidden name="userPerson.id"></s:hidden>
		
		<div class="control-group">
			<label class="control-label" for="saveUserPersonX_userPerson_name">Name</label>
			 <div class="controls">
			 	<s:textfield name="userPerson.name" label="Name" cssClass="required"/>
			 </div>
		</div>
		
		<div class="control-group">
			<label class="control-label" for="saveUserPersonX_userPerson_name">Last name</label>
			 <div class="controls">
			 	<s:textfield name="userPerson.lastName" label="Last Name" cssClass="required" />
			 </div>
		</div>
		
		<div class="control-group">
			<label class="control-label" for="saveUserPersonX_userPerson_name">User name</label>
			 <div class="controls">
			 		<s:textfield name="userPerson.account.userName" label="User" cssClass="required" minlength="5"/>
			 </div>
		</div>
		
		<div class="control-group">
			<label class="control-label" for="saveUserPersonX_userPerson_name">Password</label>
			 <div class="controls">
			 		<s:password name="userPerson.account.password" label="Password" cssClass="required" minlength="6"/>
			 </div>
		</div>
		
		<div class="control-group">
			<label class="control-label" for="saveUserPersonX_userPerson_name">E-mail</label>
			 <div class="controls">
			 	<s:textfield name="userPerson.mail" label="E-mail" cssClass="required email" />
			 </div>
		</div>
		
		<div class="control-group">
			<label class="control-label" for="saveUserPersonX_userPerson_name">User type</label>
			 <div class="controls">
			 		<s:select label="User Type" name="userPerson.userType.id" listValue="name" listKey="id" headerValue="-- Please Select --" headerKey="-1" list="userTypes" cssClass="required" /> 	<a class="btn btn-mini" href="#" onclick="showDiv()">New user type</a>
			 </div>
		</div>
	</fieldset>
	<s:submit cssClass="btn btn-success" id="buttonSave" value="Save" />
</s:form>

<div id ="newUserDiv">
	<jsp:include page="form_userType.jsp"></jsp:include>
</div>
	